feat(hooks): flip install --all to the dispatcher + migrate legacy (B, stage 2b)#607
Merged
Conversation
…(B, stage 2b) `ax hooks install --all` now registers the SINGLE dispatcher instead of N per-guard hooks, and migrates off any legacy per-guard entries - so one spawn multiplexes every guard (the #605/#606 dispatcher) and guards never double-fire. - dispatch-install.ts: - planDispatcherInstall - fan the dispatcher's per-event plan (`dispatchInstallPlan`, per-event tool matchers) across providers; command = `bun <dir>/dispatch.{ts,js}`. - planLegacyRemoval - which existing rows to drop: ONLY ax-owned entries (an `# ax:<id>` marker) whose stripped command is `bun <dir>/<guard>.{ts,js}` for THIS dir + target provider/scope. A user's own hook is never touched. - resolveDispatcherPath + installDispatcher (idempotent add + migrate). - cli.ts: --all resolves the dispatcher, calls installDispatcher, prints installed/skipped/migrated; single-file install unchanged. (export stripAxMarker) Tested without a DB: - 9 pure unit tests (plan fan-out, legacy-removal safety: skips non-ax / wrong dir / wrong provider+scope / the dispatcher itself). - integration test exercises the REAL config CRUD against a temp settings.json (project scope via repoRoot; readAllHooks(withEvidence:false) returns before touching SurrealClient, so a stub layer suffices): dispatcher entries written, legacy ax guard migrated, user hook preserved, re-run idempotent. `bun test apps/axctl/src/hooks/` -> 206 pass. typecheck -> exit 0. Stage 2b of B. Remaining: stage 3 daemon /hooks/eval fast-path (the latency win). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying ax with
|
| Latest commit: |
f8e8128
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://20075c69.ax-62d.pages.dev |
| Branch Preview URL: | https://feat-hook-dispatcher-flip.ax-62d.pages.dev |
This was referenced Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Stage 2b of the hybrid dispatcher (B), on #605 (core) + #606 (scaffold/embed). Flips
ax hooks install --allto register the single dispatcher instead of N per-guard hooks, and migrates off legacy per-guard entries. One spawn now multiplexes every guard; guards never double-fire.What
dispatch-install.ts(pure planning + thin Effect):planDispatcherInstall— fan the dispatcher's per-event plan (dispatchInstallPlan, per-event tool matchers UNION-ed) across providers;command = bun <dir>/dispatch.{ts,js}.planLegacyRemoval— which rows to drop: only ax-owned entries (an# ax:<id>marker) whose marker-stripped command isbun <dir>/<guard>.{ts,js}for this dir + target provider/scope. A user's own hook is never touched, even on a colliding command.resolveDispatcherPath+installDispatcher(idempotent add + migrate).cli.ts—--allresolves the dispatcher, callsinstallDispatcher, prints installed/skipped/migrated. Single-fileinstall <file>unchanged.Tested (no DB)
settings.json(project scope viarepoRoot).readAllHooks(withEvidence:false)returns before it touchesSurrealClient, so a never-invoked stub layer suffices — no DB needed. Asserts: dispatcher entries written, legacy ax guard migrated, user hook preserved, re-run idempotent.bun test apps/axctl/src/hooks/→ 206 pass, 0 fail.bun run typecheck→ exit 0.Migration safety
planLegacyRemovalremoves a row only if all hold: has an# ax:<id>marker (ax-owned), command matches a legacy guard path for the exact workspace dir, and provider+scope match. Hand-written hooks and the dispatcher entry itself are left alone — covered by dedicated tests.Roadmap
--allinstalls the dispatcher + migrates legacy.POST /hooks/eval+ effect-free shim (daemon-first, lazy-import bundle on fallback). The latency win.🤖 Generated with Claude Code